//
//  FriendSysTableViewCell.m
//  ChatDemo-UI2.0
//
//  Created by syun on 16/3/29.
//  Copyright © 2016年 syun. All rights reserved.
//

#import "FriendSysTableViewCell.h"

@implementation FriendSysTableViewCell
@synthesize nameLabel;
@synthesize contentLabel;
@synthesize timeLabel;
@synthesize headImage;
@synthesize logoImage;
@synthesize headBack;
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    //123
    // ignore the style argument and force the creation with style UITableViewCellStyleSubtitle
    self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier];
    

    
    if (self) {
        
        //昵称
        nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(64, 5, SCREENWIDTH - 11 - 64, 20)];
        nameLabel.font = [UIFont systemFontOfSize:15];
        nameLabel.textColor =RGBACOLOR(56, 112, 193, 1);
        nameLabel.backgroundColor =[UIColor clearColor] ;
        nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:nameLabel];
        
        headBack=[[UIView alloc]initWithFrame:CGRectMake(nameLabel.frame.origin.x, nameLabel.frame.origin.y + nameLabel.frame.size.height + 5, 50, 50)];
        headBack.backgroundColor=RGBACOLOR(243, 243, 243, 1);
        [self.contentView addSubview:headBack];
        
        //系统头像
        logoImage=[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 40, 40)];
        logoImage.backgroundColor=RGBACOLOR(243, 243, 243, 1);
        [headBack addSubview:logoImage];
        //内容
        contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(headBack.frame.origin.x+50, nameLabel.frame.origin.y + nameLabel.frame.size.height + 5, [UIScreen mainScreen].bounds.size.width-headBack.frame.origin.x-headBack.frame.size.width-11,50)];
        contentLabel.textColor = [UIColor blackColor];
        contentLabel.font = [UIFont systemFontOfSize:14];
        contentLabel.numberOfLines =2;
        contentLabel.backgroundColor=RGBACOLOR(243, 243, 243, 1);
        [self.contentView addSubview:contentLabel];
        
        //时间
        timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameLabel.frame.origin.x, headBack.frame.origin.y+50+5,nameLabel.frame.size.width,20)];
        timeLabel.font = [UIFont systemFontOfSize:13];
        timeLabel.textAlignment = NSTextAlignmentLeft;
        timeLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:timeLabel];
        
        
        //头像
        headImage = [[UIImageView alloc] initWithFrame:CGRectMake(11, 5, 42, 42)];
        headImage.contentMode = UIViewContentModeScaleAspectFill;
        headImage.clipsToBounds = YES;
        headImage.layer.cornerRadius = 21;
        [self.contentView addSubview:headImage];
        
    }
    return self;
}
-(void)upDateCellWithDic:(NSDictionary *)dict{
    
    //昵称
    self.nameLabel.text = [dict objectForKey:@"username"];
    
    //内容
    self.contentLabel.text = [dict objectForKey:@"scontent"];
    
    NSString * timeStr = [dict objectForKey:@"jointime"];
    
    timeStr = [Utils getDataStringWithoutSecondString:timeStr];
    
    self.timeLabel.text = timeStr;
}

@end
